﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace Camc.Quality.Migrations
{
    public partial class add_editfilecollect : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "EditFileProcess",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    FileProcessSpecificationId = table.Column<Guid>(nullable: false),
                    FileTechniqueExplain = table.Column<string>(nullable: true),
                    UpdateFileTechniqueExplain = table.Column<string>(nullable: true),
                    Status = table.Column<int>(nullable: false),
                    _editVersion = table.Column<string>(nullable: true),
                    FirstOperator = table.Column<string>(nullable: true),
                    FirstOperator_DisplayName = table.Column<string>(nullable: true),
                    FirstOperator_Date = table.Column<DateTime>(nullable: false),
                    FirstOperatorDate_DisplayName = table.Column<string>(nullable: true),
                    SecondOperator = table.Column<string>(nullable: true),
                    SecondOperator_DisplayName = table.Column<string>(nullable: true),
                    SecondOperator_Date = table.Column<DateTime>(nullable: false),
                    SecondOperatorDate_DisplayName = table.Column<string>(nullable: true),
                    ThirdOperator = table.Column<string>(nullable: true),
                    ThirdOperator_DisplayName = table.Column<string>(nullable: true),
                    ThirdOperator_Date = table.Column<DateTime>(nullable: false),
                    ThirdOperatorDate_DisplayName = table.Column<string>(nullable: true),
                    FourthOperator = table.Column<string>(nullable: true),
                    FourthOperator_DisplayName = table.Column<string>(nullable: true),
                    FourthOperator_Date = table.Column<DateTime>(nullable: false),
                    FourthOperatorDate_DisplayName = table.Column<string>(nullable: true),
                    FifthOperator = table.Column<string>(nullable: true),
                    FifthOperator_DisplayName = table.Column<string>(nullable: true),
                    FifthOperator_Date = table.Column<DateTime>(nullable: false),
                    FifthOperatorDate_DisplayName = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_EditFileProcess", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "BackOperationDto",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    UniqueId = table.Column<string>(nullable: true),
                    Type = table.Column<int>(nullable: false),
                    ProcessId = table.Column<Guid>(nullable: true),
                    StepId = table.Column<Guid>(nullable: true),
                    TableId = table.Column<Guid>(nullable: true),
                    RowId = table.Column<Guid>(nullable: true),
                    ColumnId = table.Column<Guid>(nullable: true),
                    OldValue = table.Column<string>(nullable: true),
                    NewValue = table.Column<string>(nullable: true),
                    TableFieldName = table.Column<string>(nullable: true),
                    FieldName = table.Column<string>(nullable: true),
                    FieldDisplayName = table.Column<string>(nullable: true),
                    EditFileProcessId = table.Column<Guid>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_BackOperationDto", x => x.Id);
                    table.ForeignKey(
                        name: "FK_BackOperationDto_EditFileProcess_EditFileProcessId",
                        column: x => x.EditFileProcessId,
                        principalTable: "EditFileProcess",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "EditFileProcessInfo",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    EditFileProcessId = table.Column<Guid>(nullable: false),
                    UniqueId = table.Column<string>(nullable: true),
                    ProcessesSequence = table.Column<int>(nullable: false),
                    ProcessesName = table.Column<string>(nullable: true),
                    ProcessesCharacteristic = table.Column<string>(nullable: true),
                    ProcessesExplain = table.Column<string>(nullable: true),
                    UpdateProcessesExplain = table.Column<string>(nullable: true),
                    UpdateProcessContent = table.Column<bool>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_EditFileProcessInfo", x => x.Id);
                    table.ForeignKey(
                        name: "FK_EditFileProcessInfo_EditFileProcess_EditFileProcessId",
                        column: x => x.EditFileProcessId,
                        principalTable: "EditFileProcess",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "EditFileStepInfo",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    EditFileProcessInfoId = table.Column<Guid>(nullable: false),
                    UniqueId = table.Column<string>(nullable: true),
                    WorkStepNumber = table.Column<string>(nullable: true),
                    WorkStepName = table.Column<string>(nullable: true),
                    WorkStepContent = table.Column<string>(nullable: true),
                    TWorkStepContent = table.Column<string>(nullable: true),
                    WorkStepUpdateContent = table.Column<string>(nullable: true),
                    WorkStepWorking = table.Column<int>(nullable: false),
                    NewStep = table.Column<bool>(nullable: false),
                    DeletedStep = table.Column<bool>(nullable: false),
                    UpdateStepContent = table.Column<bool>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_EditFileStepInfo", x => x.Id);
                    table.ForeignKey(
                        name: "FK_EditFileStepInfo_EditFileProcessInfo_EditFileProcessInfoId",
                        column: x => x.EditFileProcessInfoId,
                        principalTable: "EditFileProcessInfo",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "EditFileTableInfo",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    EditFileStepInfoId = table.Column<Guid>(nullable: false),
                    UniqueId = table.Column<string>(nullable: true),
                    FileProcessesId = table.Column<string>(nullable: true),
                    TableFieldName = table.Column<string>(nullable: true),
                    TableName = table.Column<string>(nullable: true),
                    Sort = table.Column<int>(nullable: false),
                    NewTable = table.Column<bool>(nullable: false),
                    DeletedTable = table.Column<bool>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_EditFileTableInfo", x => x.Id);
                    table.ForeignKey(
                        name: "FK_EditFileTableInfo_EditFileStepInfo_EditFileStepInfoId",
                        column: x => x.EditFileStepInfoId,
                        principalTable: "EditFileStepInfo",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "EditFileRowInfo",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    EditFileTableInfoId = table.Column<Guid>(nullable: false),
                    UniqueId = table.Column<string>(nullable: true),
                    NewRow = table.Column<bool>(nullable: false),
                    DeletedRow = table.Column<bool>(nullable: false),
                    Index = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_EditFileRowInfo", x => x.Id);
                    table.ForeignKey(
                        name: "FK_EditFileRowInfo_EditFileTableInfo_EditFileTableInfoId",
                        column: x => x.EditFileTableInfoId,
                        principalTable: "EditFileTableInfo",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "EditFileTableStructInfo",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    EditFileTableInfoId = table.Column<Guid>(nullable: false),
                    FieldName = table.Column<string>(nullable: true),
                    DisplayName = table.Column<string>(nullable: true),
                    Enable = table.Column<bool>(nullable: false),
                    Show = table.Column<bool>(nullable: false),
                    Property = table.Column<int>(nullable: false),
                    ColumnType = table.Column<int>(nullable: false),
                    Index = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_EditFileTableStructInfo", x => x.Id);
                    table.ForeignKey(
                        name: "FK_EditFileTableStructInfo_EditFileTableInfo_EditFileTableInfoId",
                        column: x => x.EditFileTableInfoId,
                        principalTable: "EditFileTableInfo",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "EditFileTableDataInfo",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    EditFileRowInfoId = table.Column<Guid>(nullable: false),
                    UniqueId = table.Column<string>(nullable: true),
                    FieldName = table.Column<string>(nullable: true),
                    DisplayName = table.Column<string>(nullable: true),
                    Enable = table.Column<bool>(nullable: false),
                    Show = table.Column<bool>(nullable: false),
                    Property = table.Column<int>(nullable: false),
                    ColumnType = table.Column<int>(nullable: false),
                    Value = table.Column<string>(nullable: true),
                    NewValue = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_EditFileTableDataInfo", x => x.Id);
                    table.ForeignKey(
                        name: "FK_EditFileTableDataInfo_EditFileRowInfo_EditFileRowInfoId",
                        column: x => x.EditFileRowInfoId,
                        principalTable: "EditFileRowInfo",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_BackOperationDto_EditFileProcessId",
                table: "BackOperationDto",
                column: "EditFileProcessId");

            migrationBuilder.CreateIndex(
                name: "IX_EditFileProcessInfo_EditFileProcessId",
                table: "EditFileProcessInfo",
                column: "EditFileProcessId");

            migrationBuilder.CreateIndex(
                name: "IX_EditFileRowInfo_EditFileTableInfoId",
                table: "EditFileRowInfo",
                column: "EditFileTableInfoId");

            migrationBuilder.CreateIndex(
                name: "IX_EditFileStepInfo_EditFileProcessInfoId",
                table: "EditFileStepInfo",
                column: "EditFileProcessInfoId");

            migrationBuilder.CreateIndex(
                name: "IX_EditFileTableDataInfo_EditFileRowInfoId",
                table: "EditFileTableDataInfo",
                column: "EditFileRowInfoId");

            migrationBuilder.CreateIndex(
                name: "IX_EditFileTableInfo_EditFileStepInfoId",
                table: "EditFileTableInfo",
                column: "EditFileStepInfoId");

            migrationBuilder.CreateIndex(
                name: "IX_EditFileTableStructInfo_EditFileTableInfoId",
                table: "EditFileTableStructInfo",
                column: "EditFileTableInfoId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "BackOperationDto");

            migrationBuilder.DropTable(
                name: "EditFileTableDataInfo");

            migrationBuilder.DropTable(
                name: "EditFileTableStructInfo");

            migrationBuilder.DropTable(
                name: "EditFileRowInfo");

            migrationBuilder.DropTable(
                name: "EditFileTableInfo");

            migrationBuilder.DropTable(
                name: "EditFileStepInfo");

            migrationBuilder.DropTable(
                name: "EditFileProcessInfo");

            migrationBuilder.DropTable(
                name: "EditFileProcess");
        }
    }
}
